package com.florent3.shapeofview.sample.slice;

import com.florent3.shapeofview.sample.ResourceTable;
import com.github.florent37.shapeofview.shapes.CutCornerMeterialDesigView;
import com.github.florent37.shapeofview.shapes.CutCornerView;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.animation.AnimatorProperty;
import ohos.agp.components.Component;
import ohos.agp.components.DependentLayout;
import ohos.agp.components.DirectionalLayout;
import ohos.agp.components.Image;
import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;

/**
 * MaterialDesignShrineAbilitySlice
 *
 * @since 2021-07-26
 */
public class MaterialDesignShrineAbilitySlice extends AbilitySlice {
    private static HiLogLabel label = new HiLogLabel(HiLog.LOG_APP, 0x00224, "MaterialDesignShrineAbilitySlice");
    private  Image  id_menu;
    private  CutCornerMeterialDesigView cutcornerview1,cutcornerview2,cutcornerview3;
    private DirectionalLayout directionallayout2;
    private DependentLayout dependentLayout_bottom,dependentLayout_bottom2;
    private  boolean enabile=true;
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_material_design_shrine);
        initView();
    }

    private void initView() {
        id_menu = (Image) findComponentById(ResourceTable.Id_menu);
        cutcornerview1=(CutCornerMeterialDesigView)findComponentById(ResourceTable.Id_cutcornerview1);
        dependentLayout_bottom=(DependentLayout)findComponentById(ResourceTable.Id_dependentLayout_bottom);
        directionallayout2=(DirectionalLayout)findComponentById(ResourceTable.Id_directionallayout2);
        cutcornerview2=(CutCornerMeterialDesigView)findComponentById(ResourceTable.Id_cutconrview2);
        cutcornerview3=(CutCornerMeterialDesigView)findComponentById(ResourceTable.Id_cutconrview3);
        dependentLayout_bottom2=(DependentLayout)findComponentById(ResourceTable.Id_dependentLayout_bottom2);
        directionallayout2.setVisibility(Component.HIDE);
        dependentLayout_bottom2.setVisibility(Component.HIDE);
         id_menu.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                HiLog.info(label,"enabile====="+enabile);
                if(enabile){
                    directionallayout2.setVisibility(Component.VISIBLE);
                    dependentLayout_bottom2.setVisibility(Component.VISIBLE);
                    directionallayout2.invalidate();
                    dependentLayout_bottom2.invalidate();
                    cutcornerview1.setVisibility(Component.HIDE);
                    dependentLayout_bottom.setVisibility(Component.HIDE);
                    cutcornerview2.updateUi();
                    cutcornerview3.updateUi();
                    enabile=false;
                }else{
                    cutcornerview1.setVisibility(Component.VISIBLE);
                    dependentLayout_bottom.setVisibility(Component.VISIBLE);
                    directionallayout2.setVisibility(Component.HIDE);
                    dependentLayout_bottom2.setVisibility(Component.HIDE);
                    enabile=true;

                }
            }
        });

    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
